package com.bstek.uflo.samplecenter;

import javax.servlet.Servlet;

import org.springframework.boot.web.servlet.ServletRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
import org.springframework.core.Ordered;

import com.bstek.uflo.console.UfloServlet;

@Configuration
public class UfloConfiguration {
	public UfloConfiguration() {
		System.out.println("uflo config...");
	}
	//PropertySourcesPlaceholderConfigurer PropertyPlaceholderConfigurer
   @Bean
    public PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer1() {
	   PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
        configurer.setOrder(Ordered.HIGHEST_PRECEDENCE);
        configurer.setIgnoreUnresolvablePlaceholders(true);
        //configurer.setLocation(new ClassPathResource("uflo-pro.properties"));
        return configurer;
    }
	@Bean
	public ServletRegistrationBean<Servlet> ufloServlet(){
		return new ServletRegistrationBean<Servlet>(new UfloServlet(), "/uflo/*");
	}
	
	/*
	 * @Bean public ServletRegistrationBean<Servlet> dispachServlet(){
	 * ServletRegistrationBean<Servlet> dispatch = new
	 * ServletRegistrationBean<Servlet>(new DispatcherServlet(), "/*"); Map<String,
	 * String> initParameters = new HashMap<String, String>();
	 * initParameters.put("contextConfigLocation", "");
	 * dispatch.setInitParameters(initParameters); return dispatch; }
	 */
	
//	@Bean
//	public InternalResourceViewResolver jspViewResolver() {
//		InternalResourceViewResolver jspViewResolver = new InternalResourceViewResolver();
//		jspViewResolver.setPrefix("/WEB-INF/");
//		jspViewResolver.setSuffix(".jsp");
//		return jspViewResolver;
//	}
	
}